package com.qf.service.impl;

import com.qf.entity.User;
import com.qf.service.UserService;
import org.apache.shiro.crypto.hash.Md5Hash;

/**
 * @author zjw
 * @description
 * @date 2021/10/13 16:11
 */
public class UserServiceImpl implements UserService {

    public static void main(String[] args) {
        Md5Hash md5Hash = new Md5Hash("admin","3jh344jhtgh4gh32ioh35iu4gjhg3h2jil",123);
        System.out.println(md5Hash.toString());
        // MD5-123 + SALT = 086be5db7c2660ce151a5d70dc5a6fd2
        // 用户输入密码：admin
        // realm：代码块中设置加密方式和次数，authen返回info前，设置盐的信息
        // 数据库： 保存加密加盐后的密码，并且需要将盐存到用户信息
    }
    @Override
    public User findByUsername(String username) {
        if("admin".equals(username)){
            User user = new User();
            user.setId(1);
            user.setUsername("admin");
            user.setPassword("086be5db7c2660ce151a5d70dc5a6fd2");
            user.setNickname("嘿嘿嘿");
            user.setSalt("3jh344jhtgh4gh32ioh35iu4gjhg3h2jil");
            return user;
        }
        return null;
    }
}
